<?php

namespace App\Http\Controllers\Admin\View;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Facades\Services\CommodityService;
use ValiDate;

class CommodityTypeController extends Controller
{
    public function index(Request $request)
    {
    	return view('pages.admin.commodityType.list',[
    		'types' => CommodityService::getTypes()
    	]);
    }

    public function create(Request $request){
    	return view('pages.admin.commodityType.create');
    }

    public function update(Request $request)
    {
        $rules = [
            'id' => 'required|exists:commodity_types,id'
        ];

        ValiDate::valiDate($request,$rules);

    	return view('pages.admin.commodityType.update',[
            'type' => CommodityService::getType($request->id)
        ]);
    }
}
